package com.wn.controller;

import com.wn.entity.User;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/prop2")
// 读取配置文件种指定的前缀配置，注入到set方法中
@ConfigurationProperties(prefix = "app2")
public class Properties2Controller {

    private String host;
    private Integer port;
    private User user;
    private List<User> list;

    @GetMapping
    public String search() {
        System.out.println("host = " + host);
        System.out.println("port = " + port);
        System.out.println("user = " + user);
        System.out.println("list = " + list);
        return "ok";
    }

    public void setHost(String host) {
        this.host = host;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setList(List<User> list) {
        this.list = list;
    }
}